package com.uniview.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.uniview.dao.ServiceOrderSmsDao;
import com.uniview.entity.po.ServiceOrderSms;
import com.uniview.service.ServiceOrderSmsService;

@Service("serviceOrderSmsService")
public class ServiceOrderSmsServiceImpl implements ServiceOrderSmsService {
	
	@Autowired
	private ServiceOrderSmsDao serviceOrderSmsDao;
	
	@Override
	public Integer saveReceipt(ServiceOrderSms sms) throws Exception {
		return (Integer)serviceOrderSmsDao.save(sms);
	}

	@Override
	public boolean deleteReceipt(String receive)throws Exception {
		String hql = "delete from ServiceOrderSms where recever ='" +receive +"'";
		return serviceOrderSmsDao.deleteByHql(hql);
	}

	@Override
	public ServiceOrderSms findServiceOrderSms(String receive) throws Exception{
		String hql = "from ServiceOrderSms where recever ='" +receive +"'";
		List<ServiceOrderSms> list = serviceOrderSmsDao.findByHql(hql);
		if(list != null && !list.isEmpty()){
			return list.get(0);
		}
		return null;
	}

}
